package com.yc.study.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yc.study.entity.Topic;
import com.yc.study.mapper.TopicMapper;
import com.yc.study.service.ITopicService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 服务实现类
 *
 * @author 王妍
 * @since 2022-02-20
 */
@Service
@AllArgsConstructor
public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements ITopicService {

  public final TopicMapper topicMapper;

  @Override
  public Page<Topic> loadPage(Page<Topic> topicPage, Topic topic) {
    final LambdaQueryWrapper<Topic> queryWrapper = new LambdaQueryWrapper<>();
    queryWrapper.like(Topic::getTitle, topic.getTitle());
    return page(topicPage, queryWrapper);
  }

  @Override
  public List<Topic> getTopicListByJobId(Long jobId) {
    return topicMapper.selectTopicListByJobId(jobId);
  }
}
